<template>
  <div v-bind="$attrs" @click="onToggle" id="guide-full">
    <svg-icon :icon="isFullscreen ? 'exit-fullscreen' : 'fullscreen'"></svg-icon>
  </div>
</template>

<script setup>
import { onMounted, onUnmounted, ref } from 'vue'
import screenfull from 'screenfull'

// 是否全屏
const isFullscreen = ref(false)

// 点击全屏
const onToggle = () => {
  screenfull.toggle()
}

// 监控全屏事件
const change = () => {
  isFullscreen.value = screenfull.isFullscreen
}

onMounted(() => {
  screenfull.on('change', change)
})

onUnmounted(() => {
  screenfull.off('change', change)
})

</script>
<style lang="scss" scoped>
</style>
